
var specialToListEvent=function(){
    $(".specialToList").unbind('click').click(function(){
        var arr2={
            'qctpType':'kp',
            'id':$(this).attr("data-id"),
            'qctpName':$(this).attr("data-name")
        };
        $.cookie('qctpBool',JSON.stringify(arr2));
    })
};
var specialQtListEvent=function(){
    $(".specialTypesList").unbind('click').click(function(){
        var arr2={
            'qctpType':'qt',
            'id':$(this).attr("data-id"),
            'qctpName':$(this).attr("data-name")
        };
        $.cookie('qctpBool',JSON.stringify(arr2));
    })
};
var viewEvent=function(arrays){
    var specialArr=arrays;
    if(specialArr.length>0){
        $(".specialSpotListWrap").empty();
        var li='';
        var bi='';
        var ti='';
        for(var i=0;i<specialArr.length;i++){
            var specialBig=specialArr[i]['bg_list'];
            li+=' <div class="specialSpotList">\n' +
                '                            <div class="spotBg" style="background-image:url(\'images/spot1.png\')"></div>\n' +
                '                            <div class="spotTxt">'+specialArr[i]['kp_desc']+'</div>\n' +
                '                            <div class="specialSpotExplain">\n'
            for(var j=0;j<specialBig.length;j++){
                var specialSmall=specialBig[j]['sg_list'];
                bi+= '                                <h3>'+specialBig[j]['kp_bg_desc']+'</h3>\n' +
                    '                                <ul>\n'
                for(var t=0;t<specialSmall.length;t++){
                    ti+='<li class="specialToList" data-id="'+specialSmall[t]['kp_bg_id']+'"  data-name="'+specialArr[i]['kp_desc']+'"><a href="overyears.html">'+specialSmall[t]['kp_sg_desc']+'</a></li>\n'
                }
                bi+=ti+'</ul>\n';
                ti='';
            }
            li+=bi+'</div></div>';
            bi='';
        }
        $(".specialSpotListWrap").html(li);
        specialToListEvent();
    }
};

var topicList=function(){
    var arr1={
        'auth_token':tokens,
        'page_no':1,
        'page_size':18
    };
    $.ajax({
        type: "GET",
        url:base_url + "qt/list_category",
        data:arr1,
        beforeSend:function(XMLHttpRequest){},
        success:function(data){
            var datas=data.data;
            if(datas){
                $(".specialTypesListWrap").empty();
                var page_contents=datas.page_contents;
                for(var i=0;i<page_contents.length;i++){
                    var category_desc=page_contents[i].category_desc;
                    var category_id=page_contents[i].category_id;
                    var txt=[
                        '四大题型中的第一个，大多数是四选一，每题有且仅有一个正确选项。',
                        '四大题型中的第二个，根据题干描述的问题分析解题思路写出对应答案。',
                        '四大题型中的第三个，阅读给出的程序，根据输入内容写出输出结果。',
                        '四大题型中的第四个，根据题目要求将题干中的程序补充完整。'
                    ];
                    var li=' <div class="specialTypesList" data-id="'+category_id+'" data-name="'+category_desc+'">\n' +
                        '<a href="overyears.html">' +
                        '                            <h2>'+category_desc+'</h2>\n' +
                        '                            <p>'+txt[i]+'</p>\n' +
                        '</a>';
                    '    </div>'
                    $(".specialTypesListWrap").append(li);
                }
                specialQtListEvent()
            }
        },
        error:function(){
            console.log('失败')
        }

    });
    var arr2={
        'auth_token':tokens,
        'page_no':1,
        'page_size':18
    };
    $.ajax({
        type: "GET",
        url:base_url +'kp/list_kp_c',
        data:arr2,
        success:function(data){
            var datas=data.data;
            if(datas){
                viewEvent(datas);
            }
        },
        error:function(){
            console.log('失败')
        }
    });
};
$(function(){
    //判断token
    if(tokens){
        topicList();
    }else{
        layTxt('您还没登录!');
        setTimeout(function(){
            setUrl('special','login')//设置跳转
        },1000)
    }
    //echarts
    var echartData={
        "dataX":['0', '1', '2', '3', '4', '5', '6'],
        "dataY":[820, 932, 901, 934, 1290, 1330, 1320]
    };
    echartEvent(echartData)
});